﻿#------------------------------------------------------------------------------#
# · Let's poke fun of newgrounds with chip8.
#------------------------------------------------------------------------------#

:alias game_screen vd
:alias sprx vc
:alias spry vb
:alias title_count va
:alias keypressed v9
:alias game_count v8
:alias keypressed v7
:alias zbut v6
:alias xbut v5
:alias cbut v4

: sx_title # (256 bytes)
0x00 0xDA 0x16 0x12 0xD2 0x00 0xDE 0x10
0x00 0x5B 0x61 0x51 0x4B 0x00 0x7B 0x72
0x00 0xEF 0x69 0x2F 0x28 0x00 0xEF 0x2E
0x00 0xA5 0xA5 0xA5 0x3D 0x00 0x39 0x25
0x00 0x07 0x04 0x07 0x84 0xE0 0x58 0x26
0x00 0x70 0x88 0x88 0x07 0xFF 0x82 0x01
0x00 0x20 0x20 0x18 0x07 0x7F 0xB1 0x42
0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x06
0xDE 0xCE 0x00 0x00 0x5E 0x52 0x5E 0xD0
0x43 0x79 0x00 0x00 0x02 0x02 0x02 0x03
0xE8 0x4F 0x00 0x00 0x00 0x00 0x00 0x00
0x25 0xB9 0x80 0x40 0x40 0xE0 0xF0 0x2C
0x21 0x40 0x00 0x00 0xEE 0x9F 0xFF 0xCD
0x01 0x00 0x00 0x00 0x00 0x00 0x01 0x06
0x84 0x04 0x00 0x00 0x00 0x00 0x00 0x00
0x09 0x12 0x14 0x24 0x20 0x40 0x40 0x40
0x00 0x01 0x07 0x0F 0x1F 0x7E 0xF8 0xF0
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
0x00 0x80 0x40 0x40 0x20 0x20 0x20 0x20
0x93 0x90 0x20 0x00 0x00 0x00 0x00 0x00
0x08 0x10 0x10 0x00 0x00 0x00 0x00 0x00
0x19 0x26 0x48 0x50 0x90 0x80 0x80 0x80
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x40 0x40 0x40 0x40 0x40 0x40 0x20 0x22
0xC3 0x87 0x1F 0x3E 0xFC 0xF8 0xC3 0x87
0x07 0x0F 0x1F 0x7C 0xF8 0xE1 0xC7 0x0F
0x20 0x20 0x20 0x40 0x80 0x01 0x07 0x0F
0x00 0x00 0x02 0x42 0x44 0x9B 0xFC 0x00
0x00 0x00 0x00 0x10 0x10 0x0D 0xFF 0x00
0x80 0x80 0x88 0xC8 0x24 0x1B 0x07 0x00
0x04 0x04 0xC3 0xFF 0x00 0x00 0x00 0x00
0x12 0x09 0x06 0x01 0x00 0x00 0x00 0x00


: xload # (256 bytes)
        0x7D 0x5D 0x7D 0x5D 0x7D 0x5D 0x7D 0x5D
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xFF 0x00 0x00 0x00 0x00 0x60 0xD0 0xF0
        0xFF 0x00 0x00 0x00 0x00 0x00 0x01 0x03
        0xFF 0x00 0x00 0x20 0x20 0x20 0x50 0x50
        0xFF 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xBA 0xBE 0xBA 0xBE 0xBA 0xBE 0xBA 0xBE
        0x7D 0x5D 0x7D 0x5D 0x7D 0x5D 0x7D 0x5D
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xC0 0x00 0x00 0x00 0x00 0x00 0x00 0x00
        0x0F 0x1F 0xFE 0x7C 0x74 0x84 0x8E 0x82
        0x5C 0x74 0xFB 0xFA 0xFF 0xE1 0xF0 0xFC
        0x00 0x00 0x00 0x01 0x03 0x03 0x03 0x03
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xBA 0xBE 0xBA 0xBE 0xBA 0xBE 0xBA 0xBE
        0x7D 0x5D 0x7D 0x5D 0x7D 0x5D 0x7D 0x5D
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0x80 0xE0 0x10 0x10 0x10 0x10 0x30 0x7F
        0x81 0xFF 0xFE 0xFE 0xFE 0xFE 0xEC 0x9C
        0xFF 0xF8 0x78 0xF8 0xF0 0xF0 0xB1 0x61
        0x03 0x07 0x0E 0x1D 0x3B 0x3F 0x3F 0xBE
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xBA 0xBE 0xBA 0xBE 0xBA 0xBE 0xBA 0xBE
        0x7D 0x5D 0x7D 0x5D 0x7D 0x5D 0x7D 0x5D
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xFF 0xFF 0xFF 0x00 0x6C 0x6C 0x00 0xFF
        0xF8 0xF9 0xFF 0x00 0x4D 0x69 0x00 0xFF
        0xC3 0xC7 0xFF 0x00 0x66 0x46 0x00 0xFF
        0xDF 0xFF 0xFF 0x00 0x69 0x6D 0x00 0xFF
        0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
        0xBA 0xBE 0xBA 0xBE 0xBA 0xBE 0xBA 0xBE
: sxbg
0x00 0x00 0xF0 0x10 0xD0 0x50 0xD0 0x50
0x00 0x00 0x0F 0x08 0x0B 0x0A 0x0B 0x0A
0x00 0x00 0x00 0x00 0x00 0x00 0x80 0x60
0x00 0x00 0xC0 0x20 0x20 0x1E 0xFF 0x09
0x00 0x00 0x81 0x82 0x62 0x1C 0xFF 0xC6
0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x06
0x00 0xF0 0x10 0xD0 0x90 0x10 0xD0 0x10
0x00 0x0F 0x08 0x0B 0x08 0x09 0x0B 0x08
0x10 0xF0 0x00 0x00 0xF0 0x10 0xD0 0x50
0x08 0x0F 0x00 0x00 0x0F 0x08 0x8B 0x8A
0x98 0x84 0x02 0x02 0x01 0x01 0x00 0x00
0x04 0x04 0x01 0x00 0x00 0x00 0x00 0x00
0x08 0x10 0x10 0x00 0x00 0x00 0x00 0x00
0x19 0x26 0x48 0x50 0x90 0x80 0x00 0x00
0xF0 0x00 0x00 0xF0 0x10 0x50 0x91 0x91
0x0F 0x00 0x00 0x0F 0x08 0x0A 0x09 0x09
0x50 0xD0 0x10 0xF0 0x00 0x00 0xF0 0x10
0x8A 0x8B 0x88 0x8F 0x80 0x80 0x8F 0x08
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x80
0x51 0x11 0xF1 0x01 0x01 0x01 0xF1 0x10
0x0A 0x08 0x0F 0x00 0x00 0x00 0x0F 0x08
0x10 0x90 0x50 0xD0 0x10 0xF0 0x00 0x00
0x0B 0x0A 0x0B 0x0B 0x08 0x0F 0x00 0x00
0x11 0x12 0x24 0xD8 0xE0 0x00 0x00 0x00
0x00 0x02 0x02 0x0C 0xFF 0x00 0x00 0x00
0x00 0x10 0x10 0x0C 0xFF 0x00 0x00 0x00
0x88 0x48 0x24 0x1B 0x07 0x00 0x00 0x00
0xD0 0x10 0x10 0xD0 0x10 0xF0 0x00 0x00
0x0B 0x0A 0x0A 0x0B 0x08 0x0F 0x00 0x00

: happyeye
0x20 0x70 0xD8 0x70 0x20

: supriseeye
0x70 0x88 0x88 0xA8 0x70 

: evileye1
0x80 0xC0 0xF0 0xF8 0x70

: evileye2
0x08 0x18 0x78 0xF8 0x70 

: mouthsq
0xC0 0xC0

: mouthtou
0xFF 0x49 0x49 0x22 0x1C 

: bat
0x28 0x7C 0xD6 0xFE 0x82 0x44 

: mole
0x80

: nose
0x90 0x60
#------------------------------------------------------------------------------#
# · Draw Full Screen Image
#------------------------------------------------------------------------------#
: draw_fullscreen
	sprx := 56  # x
	spry := 0   # y 	
	title_count := 8   # stride
	loop
		sprite sprx spry 8
		i  += title_count
		sprx += -8
		if sprx == -8 then spry +=  8
		if sprx == -8 then sprx := 56
		if spry != 32 then
	again
return
	

#------------------------------------------------------------------------------#
# · Main Loop
#------------------------------------------------------------------------------#
: main
	loop
		if game_screen == 0 then title	
		if game_screen == 1 then zload	
		if game_screen == 2 then bgdraw		
		if game_screen == 3 then flashgameplay		
		again
	return 

#------------------------------------------------------------------------------#
# · Title
#------------------------------------------------------------------------------#

: title
	i := sx_title
	draw_fullscreen

		keypressed := key # Did they press ANYTHING?
		if keypressed >= 0 begin
			game_screen := 1
			clear
			return
		end
#------------------------------------------------------------------------------#
# · Fake load screen for giggles
#------------------------------------------------------------------------------#
: zload
	i := xload
	draw_fullscreen

		loop
		game_count += 1
			i := xload
	draw_fullscreen
		if game_count != 5 then again
		clear
		game_screen := 2
		return
					
#------------------------------------------------------------------------------#
# · Draw the character sprite
#------------------------------------------------------------------------------#
: bgdraw
	i := sxbg
	draw_fullscreen
	game_screen := 3
	return	
#------------------------------------------------------------------------------#
# · Game loop for pumpkin faces
#------------------------------------------------------------------------------#

: flashgameplay
loop
	checkbutt
again

return

#------------------------------------------------------------------------------#
# · Check Input
#------------------------------------------------------------------------------#
: checkbutt
	keypressed := key # Did they press ANYTHING?
	if keypressed == 0xA begin
		zbut += 1
		if zbut == 5 begin
			zbut := 0
		end
		redrawall
	end
	if keypressed == 0x0 begin
		xbut += 1
		if xbut == 7 begin
			xbut := 0
		end
		redrawall
	end
	if keypressed == 0xB begin
		cbut += 1
		if cbut == 5 begin
			cbut := 0
		end
		redrawall
	end
return

#------------------------------------------------------------------------------#
# · Draw New Faces
#------------------------------------------------------------------------------#
: redrawall
	clear
	bgdraw
	draweyes
	drawacc
	drawmouth
return

#------------------------------------------------------------------------------#
# · Accessories
#------------------------------------------------------------------------------#
: drawacc
	if zbut == 1 then acc_1
	if zbut == 2 then acc_2
	if zbut == 3 then acc_3
	if zbut == 4 then acc_4
return

#------------------------------------------------------------------------------#
# · acc_1
#------------------------------------------------------------------------------#
: acc_1
	i := bat
	sprx := 14
	spry := 1 
	sprite sprx spry 6
	sprx := 43
	spry := 2 
	sprite sprx spry 6
return

#------------------------------------------------------------------------------#
# · acc_2
#------------------------------------------------------------------------------#
: acc_2
	i := mole
	sprx := 42
	spry := 17 
	sprite sprx spry 1
return

#------------------------------------------------------------------------------#
# · acc_3
#------------------------------------------------------------------------------#
: acc_3
	i := nose
	sprx := 30
	spry := 16 
	sprite sprx spry 2
return

#------------------------------------------------------------------------------#
# · acc_4
#------------------------------------------------------------------------------#
: acc_4
	i := nose
	sprx := 30
	spry := 25 
	sprite sprx spry 2
return
#------------------------------------------------------------------------------#
# · Eyes
#------------------------------------------------------------------------------#
: draweyes
	if xbut == 1 then eye_1
	if xbut == 2 then eye_2
	if xbut == 3 then eye_3
	if xbut == 4 then eye_4
	if xbut == 5 then eye_5
	if xbut == 6 then eye_6
return

#------------------------------------------------------------------------------#
# · EYE_1
#------------------------------------------------------------------------------#
: eye_1
	i := happyeye
	sprx := 24
	spry := 12
	sprite sprx spry 3
	sprx := 35
	sprite sprx spry 3
return
#------------------------------------------------------------------------------#
# · EYE_2
#------------------------------------------------------------------------------#
: eye_2
	i := supriseeye
	sprx := 24
	spry := 12
	sprite sprx spry 6
	sprx := 35
	sprite sprx spry 6
return
#------------------------------------------------------------------------------#
# · EYE_3
#------------------------------------------------------------------------------#
: eye_3
	i := evileye1
	sprx := 24
	spry := 12
	
	sprite sprx spry 5
	sprx := 35
	i := evileye2
	sprite sprx spry 5
return

#------------------------------------------------------------------------------#
# · EYE_4
#------------------------------------------------------------------------------#
: eye_4
	i := evileye2
	sprx := 24
	spry := 12
	
	sprite sprx spry 5
	sprx := 35
	i := evileye1
	sprite sprx spry 5
return
#------------------------------------------------------------------------------#
# · EYE_5
#------------------------------------------------------------------------------#
: eye_5
	i := happyeye
	sprx := 24
	spry := 12
	sprite sprx spry 5
	sprx := 35
	sprite sprx spry 5
return
#------------------------------------------------------------------------------#
# · EYE_6
#------------------------------------------------------------------------------#
: eye_6
	i := happyeye
	sprx := 24
	spry := 12
	sprite sprx spry 5
	i := mouthtou
	sprx := 33
	spry := 14
	sprite sprx spry 1
return
#------------------------------------------------------------------------------#
# · Mouth
#------------------------------------------------------------------------------#
: drawmouth
	if cbut == 1 then mou_1
	if cbut == 2 then mou_2
	if cbut == 3 then mou_3
	if cbut == 4 then mou_4
return

#------------------------------------------------------------------------------#
# · mou_1 # Should be a loop, but deadlines
#------------------------------------------------------------------------------#
: mou_1
	i := mouthsq
	sprx := 23
	spry := 20
	sprite sprx spry 2
	sprx := 25
	spry := 21
	sprite sprx spry 2
	sprx := 27
	spry := 20
	sprite sprx spry 2
	sprx := 29
	spry := 21
	sprite sprx spry 2
	sprx := 31
	spry := 20
	sprite sprx spry 2
	sprx := 33
	spry := 21
	sprite sprx spry 2
	sprx := 35
	spry := 20
	sprite sprx spry 2
	sprx := 37
	spry := 21
	sprite sprx spry 2
	sprx := 39
	spry := 20
	sprite sprx spry 2
return
#------------------------------------------------------------------------------#
# · mou_2
#------------------------------------------------------------------------------#
: mou_2
	i := mouthsq
	sprx := 23
	spry := 21
	sprite sprx spry 2
	sprx := 25
	spry := 20
	sprite sprx spry 2
	sprx := 27
	spry := 21
	sprite sprx spry 2
	sprx := 29
	spry := 20
	sprite sprx spry 2
	sprx := 31
	spry := 21
	sprite sprx spry 2
	sprx := 33
	spry := 20
	sprite sprx spry 2
	sprx := 35
	spry := 21
	sprite sprx spry 2
	sprx := 37
	spry := 20
	sprite sprx spry 2
	sprx := 39
	spry := 21
	sprite sprx spry 2
return
#------------------------------------------------------------------------------#
# · mou_3
#------------------------------------------------------------------------------#
: mou_3
	i := mouthsq
	sprx := 23
	spry := 21
	sprite sprx spry 1
	sprx := 25
	spry := 21
	sprite sprx spry 1
	sprx := 27
	spry := 21
	sprite sprx spry 1
	sprx := 29
	spry := 21
	sprite sprx spry 1
	sprx := 31
	spry := 21
	sprite sprx spry 1
	sprx := 33
	spry := 21
	sprite sprx spry 1
	sprx := 35
	spry := 21
	sprite sprx spry 1
	sprx := 37
	spry := 21
	sprite sprx spry 1
	sprx := 39
	spry := 21
	sprite sprx spry 1
return

#------------------------------------------------------------------------------#
# · mou_4
#------------------------------------------------------------------------------#
: mou_4
i := mouthsq
	sprx := 23
	spry := 21
	sprite sprx spry 1
	sprx := 25
	spry := 21
	sprite sprx spry 1
	sprx := 27
	spry := 21
	sprite sprx spry 1
	sprx := 29
	spry := 21
	sprite sprx spry 1
i := mouthtou
	sprx := 31
	spry := 21
	sprite sprx spry 5
return